{{define "cp_automod_legacy"}}
{{template "cp_head" .}}
<header class="page-header">
    <h2>Automoderator {{if .AutomodConfig.Enabled}}<span class="bg-success">Enabled</span>{{else}}<span
            class="bg-danger">Disabled</span>{{end}}</h2>
</header>

{{template "cp_alerts" .}}
<!-- /.row -->
<form method="post" data-async-form>
    <div class="row">
        <div class="col-lg-12">
            <!-- Nav tabs -->
            <div class="tabs">
                <ul class="nav nav-tabs">
                    <li class="nav-item active"><a class="nav-link show active" href="#general" aria-controls="general"
                            role="tab" data-toggle="tab">
                            General
                        </a></li>
                    <li class="nav-item"><a class="nav-link" href="#spam" aria-controls="spam" role="tab"
                            data-toggle="tab">
                            Slowmode <span
                                class="indicator {{if .AutomodConfig.Spam.Enabled}}indicator-success{{else}}indicator-danger{{end}}"></span>
                        </a></li>
                    <li class="nav-item"><a class="nav-link" href="#mass-mention" aria-controls="mass-mention"
                            role="tab" data-toggle="tab">
                            Mass Mention <span
                                class="indicator {{if .AutomodConfig.Mention.Enabled}}indicator-success{{else}}indicator-danger{{end}}"></span>
                        </a></li>
                    <li class="nav-item"><a class="nav-link" href="#invites" aria-controls="invites" role="tab"
                            data-toggle="tab">
                            Server Invites <span
                                class="indicator {{if .AutomodConfig.Invite.Enabled}}indicator-success{{else}}indicator-danger{{end}}"></span>
                        </a></li>
                    <li class="nav-item"><a class="nav-link" href="#links" aria-controls="links" role="tab"
                            data-toggle="tab">
                            Links <span
                                class="indicator {{if .AutomodConfig.Links.Enabled}}indicator-success{{else}}indicator-danger{{end}}"></span>
                        </a></li>
                    <li class="nav-item"><a class="nav-link" href="#banned-words" aria-controls="banned-words"
                            role="tab" data-toggle="tab">
                            Banned words <span
                                class="indicator {{if .AutomodConfig.Words.Enabled}}indicator-success{{else}}indicator-danger{{end}}"></span>
                        </a></li>
                    <li class="nav-item"><a class="nav-link" href="#banned-websites" aria-controls="banned-websites"
                            role="tab" data-toggle="tab">
                            Banned websites <span
                                class="indicator {{if .AutomodConfig.Sites.Enabled}}indicator-success{{else}}indicator-danger{{end}}"></span>
                        </a></li>
                </ul>

                <!-- Tab panesy -->
                <div class="tab-content">
                    <div role="tabpanel" class="tab-pane active" id="general">{{template "automod_legacy_general" .}}
                    </div>
                    <div role="tabpanel" class="tab-pane" id="spam">{{template "automod_legacy_spam" .}}</div>
                    <div role="tabpanel" class="tab-pane" id="mass-mention">{{template "automod_legacy_mention" .}}
                    </div>
                    <div role="tabpanel" class="tab-pane" id="invites">{{template "automod_legacy_invite" .}}</div>
                    <div role="tabpanel" class="tab-pane" id="links">{{template "automod_legacy_links" .}}</div>
                    <div role="tabpanel" class="tab-pane" id="banned-words">{{template "automod_legacy_banned_words" .}}
                    </div>
                    <div role="tabpanel" class="tab-pane" id="banned-websites">
                        {{template "automod_legacy_banned_websites" .}}</div>
                </div>
            </div>
        </div>
        <!-- /.col-lg-12 -->
    </div>
    <div class="row">
        <div class="col-lg-12">
            <button type="submit" class="btn btn-success btn-lg btn-block">Save All Settings</button>
        </div>
    </div>
</form>
<!-- /.row -->
{{template "cp_footer" .}}
{{end}}

<!-- GENERAL -->
{{define "automod_legacy_general"}}
<div class="row">
    <div class="col-lg-12">
        {{checkbox "Enabled" "automod-enabled" "Enable basic automoderator" .AutomodConfig.Enabled}}
    </div>
</div>
<div class="row">
    <div class="col-lg-12">
        <h3>Basic automod</h3>
        <p>This is the basic automod with limited functionality, if you want more flexibility then use automodv2,
            although it's quite a bit more complex</p>
        <p>The automoderator helps to perform mundane and repetitive duties on servers. It deals with the following
            cases:</p>
        <ul>
            <li><b>Slowmode:</b> You can set up a rule to only allow up to a certain amount of messages within a certain
                amount of seconds.</li>
            <li><b>Mass mentions:</b> You can set up a rule to detect messages which contain more than a certain amount
                of mentions in them.</li>
            <li><b>Invite links:</b> You can set up a rule for invite links (for example, delete every invite link if
                the poster doesn't have a certain role).</li>
            <li><b>Links:</b> You can restrict posting any kind of link to a certain role.</li>
            <li><b>Bad words/websites:</b> YAGPDB comes with a built-in list of bad sites and swear words you can use if
                you want, or you can define your own.</li>
        </ul>
        <p><b>TIP:</b> The ban and kick message from the moderation settings will be used when the bot kicks and bans.
        </p>
        <p><b>Check out the documentation for more info: <a
                    href="https://help.yagpdb.xyz/docs/moderation/basic-automoderator/">help.yagpdb.xyz/docs/moderation/basic-automoderator/.</a></b>
            <p>If you need any help setting up a rule, join the <a href="https://discord.gg/4udtcA5">support server </a></p>
    </div>
</div>
{{end}}

<!-- SPAM -->
{{define "automod_legacy_spam"}}
<div class="col-lg-12">
    {{mTemplate "automod_legacy_common_fields" "Guild" .ActiveGuild "Rule" .AutomodConfig.Spam "Name" "Spam"}}

    <div class="form-group">
        <label for="NumMessages">Number of messages:</label>
        <input type="number" min="1" class="form-control" name="Spam.NumMessages"
            value="{{.AutomodConfig.Spam.NumMessages}}"></input>
        <p class="help-block">Number of messages sent within the time frame below for it to be triggered:</p>
    </div>
    <div class="form-group">
        <label for="Within">Within (seconds):</label>
        <input type="number" min="1" class="form-control" name="Spam.Within" value="{{.AutomodConfig.Spam.Within}}"></input>
        <p class="help-block">The timeframe to check messages from.</p>
    </div>
    <p>Something decent to just protect from raw spam could be five messages within two seconds. Normal users won't come
        near that, and it would target spammers.</p>
</div>
{{end}}

<!-- MASS MENTION -->
{{define "automod_legacy_mention"}}
<div class="col-lg-12">
    {{mTemplate "automod_legacy_common_fields" "Guild" .ActiveGuild "Rule" .AutomodConfig.Mention "Name" "Mention"}}

    <div class="form-group">
        <label for="Treshold">Mention Threshold</label>
        <input type="number" min="1" class="form-control" name="Mention.Treshold"
            value="{{.AutomodConfig.Mention.Treshold}}"></input>
        <p class="help-block">The number of mentions in a message for it to trigger.<br>
            If it's set to 5, then someone mentioning five people or more would trigger this.</p>
    </div>

</div>
{{end}}

<!-- SERVER INVITE -->
{{define "automod_legacy_invite"}}
<div class="col-lg-12">
    {{mTemplate "automod_legacy_common_fields" "Guild" .ActiveGuild "Rule" .AutomodConfig.Invite "Name" "Invite"}}
</div>
{{end}}

<!-- ALL LINKS -->
{{define "automod_legacy_links"}}
<div class="col-lg-12">
    {{mTemplate "automod_legacy_common_fields" "Guild" .ActiveGuild "Rule" .AutomodConfig.Links "Name" "Links"}}
</div>
{{end}}

<!-- BANNED WORDS -->
{{define "automod_legacy_banned_words"}}
<div class="col-lg-12">
    {{mTemplate "automod_legacy_common_fields" "Guild" .ActiveGuild "Rule" .AutomodConfig.Words "Name" "Words"}}

    <p class="help-block">Built in lists</p>
    {{checkbox "Words.BuiltinSwearWords" "Words-BuiltinSwearWords" `Ban builtin swear words <a href="https://github.com/botlabs-gg/yagpdb/blob/master/automod_legacy/swearwords.go"> (list of swear words here)</a>` .AutomodConfig.Words.BuiltinSwearWords}}
    <hr />

    <div class="form-group">
        <label>Banned words</label>
        <p class="help-block"> Separate entries by spaces or lines, this is case insensitive and it only checks against
            words.</p>
        <textarea class="form-control" name="Words.BannedWords"
            rows="10">{{.AutomodConfig.Words.BannedWords}}</textarea>
    </div>
</div>
{{end}}
<!-- END BANNED WORDS -->

<!-- BANNED WEBSITES -->
{{define "automod_legacy_banned_websites"}}
<div class="col-lg-12">
    {{mTemplate "automod_legacy_common_fields" "Guild" .ActiveGuild "Rule" .AutomodConfig.Sites "Name" "Sites"}}
    {{checkbox "Sites.GoogleSafeBrowsingEnabled" "automod-google-safebrowsing" `Enable <b>Google safebrowsing</b> integration` .AutomodConfig.Sites.GoogleSafeBrowsingEnabled}}
    <p>Detects sites that contains malware, scams, and other dangerous sites</p>
    <hr />

    {{checkbox "Sites.ScamLinkProtection" "automod-scamlink-protection" `Enable <b>Scam link protection </b>` .AutomodConfig.Sites.ScamLinkProtection}}
    <p>Detects common scam links on Discord</p>
    <hr />

    <div class="form-group">
        <label>User-defined banned sites</label>
        <p class="help-block"> Separate entries by spaces or lines<br />Only type the host. For example, if you want to
            block Google, you would add <code>google.com</code>, NOT <code>https://google.com</code>.<br>
            This will also ban all subdomains of the site, for example, if you ban <code>google.com</code> then
            <code>fun.google.com</code> will also be banned.</p>
        <textarea class="form-control" name="Sites.BannedWebsites"
            rows="10">{{.AutomodConfig.Sites.BannedWebsites}}</textarea>
    </div>
</div>
{{end}}
<!-- END BANNED WEBSITES -->

<!-- COMMON RULE FIELDS -->
{{define "automod_legacy_common_fields"}}

<br />
{{checkbox (print .Name ".Enabled") (print .Name ".Enabled") "Enabled" .Rule.Enabled}}
<hr />
<div class="form-group">
    <label for="ViolationsExpire">Violations expire after (minutes):</label>
    <input type="number" min="0" max="44640" class="form-control" name="{{.Name}}.ViolationsExpire"
        value="{{.Rule.ViolationsExpire}}"></input>
    <p class="help-block">When this many minutes have passed without any violations, the users violations are forgotten,
        maximum is one month (44640 minutes).</p>
</div>
<hr />

<div class="form-group row">
    <div class="col-lg-2">
        <label for="MuteAfter">Mute after: <small>(Set up role in moderation)</small></label>
        <input type="number" min="0" class="form-control" placeholder="" value="{{.Rule.MuteAfter}}" name="{{.Name}}.MuteAfter">
    </div>

    <div class="col-lg-3">
        <label for="BanAfter">Mute duration <b>(minutes)</b>:</label>
        <input type="number" min="0" class="form-control" placeholder="" value="{{.Rule.MuteDuration}}"
            name="{{.Name}}.MuteDuration">
    </div>

    <div class="col-lg-3 col-lg-offset-1">
        <label for="KickAfter">Kick after:</label>
        <input type="number" min="0" class="form-control" placeholder="" value="{{.Rule.KickAfter}}" name="{{.Name}}.KickAfter">
    </div>
    <div class="col-lg-3">
        <label for="BanAfter">Ban after <b>(Be careful with this)</b>:</label>
        <input type="number" min="0" class="form-control" placeholder="" value="{{.Rule.BanAfter}}" name="{{.Name}}.BanAfter">
    </div>
</div>
<p class="help-block">Punish based on number of violations >:O. (Punishment is disabled if set below 1.)</p>
<p class="help-block">A warning and message deletion will always be issued if the rule is broken.</p>
<hr />

<div class="form-group">
    <label for="IgnoreRole">Ignore role:</label>
    <select id="channel" class="form-control" name="{{.Name}}.IgnoreRole">
        {{roleOptions .Guild.Roles nil .Rule.IgnoreRole "None"}}
    </select>
</div>

<div class="form-group">
    <label for="IgnoreChannels">Ignore channels:</label>
    <select name="{{.Name}}.IgnoreChannels" class="multiselect" multiple="multiple" id="{{.Name}}"
        data-plugin-multiselect>
        {{textChannelOptionsMulti .Guild.Channels (.Rule.IgnoreChannelsParsed)}}
    </select>
</div>
<hr />
<script>
  $(function(){
    $('.deleted-channel').each(function(i,v) {
      v.selected = false
    })
  })
</script>
{{end}}
<!-- END COMMON RULE FIELDS -->
